<?php
namespace Admin\Controller;
/**
 * 同步数据表
 * User: linkwhy
 * Date: 2015/12/7
 * Time: 9:55
 */
class SynchroInfoController extends AdminController{

    public function index(){
        $pageShow = 20;
        //kaieers
        $c1 = M('clients');
        $c2 = M('clients','caitou_','DB_CONFIG1');  //mock
        $c3 = M('clients','caitou_','DB_CONFIG2');  //joes
        $this->list_kaieers = $c1->field('uid,open_name,bank_account,open_bank_name')->order('id desc')->limit($pageShow)->select();
        $this->list_mock = $c2->field('uid,open_name,bank_account,open_bank_name')->order('id desc')->limit($pageShow)->select();
        $this->list_joes = $c3->field('uid,open_name,bank_account,open_bank_name')->order('id desc')->limit($pageShow)->select();
        $this->display();
    }

    /**
     * 同步数据
     */
    public function synchData(){
        $c1 = M('clients');
        $c2 = M('clients','caitou_','DB_CONFIG1');  //mock
        $c3 = M('clients','caitou_','DB_CONFIG2');  //joes
        $kaieers_count = $c1->count();
        $mock_count = $c2->count();
        $joes_count = $c3->count();

        $data = array($kaieers_count, $mock_count, $joes_count);

        for($i = 0; $i < 3; $i ++){
            for($k = 2; $k > $i; $k --){
                if( $data[$k] > $data[$k - 1] ){
                    $tmp = $data[$k];
                    $data[$k] = $data[$k - 1];
                    $data[$k - 1] = $tmp;
                }
            }
        }



    }

}